package figurs;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;

public class TrepezeTop extends Shape {
	static PointList points = new PointList();
	protected static int whitht;
	protected void fillShape(Graphics graphics) {
		graphics.fillPolygon(getPoints(getBounds()));
	}
	public TrepezeTop(int w){
		whitht=w;
	}
	protected void outlineShape(Graphics graphics) {
		graphics.drawPolygon(getPoints(getBounds()));
	}

	private static PointList getPoints(Rectangle r) {
		points.removeAllPoints();
		Point p = r.getTop();
		p.setX(p.x - ((int) whitht/6));
		points.addPoint(p);
		p = r.getTop();
		p.setX(p.x +((int) whitht/6));
		points.addPoint(p);
		p = r.getBottomRight();
		p.setY(p.y - 1);
		points.addPoint(p);
		p = r.getBottomLeft();
		p.setY(p.y - 1);
		points.addPoint(p);

		return points;
	}
}